<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function* getData(){
            console.log(1);
            yield console.log(1);
            yield console.log(2);
            yield console.log(3);
            yield console.log(4);
            yield console.log(5);
            yield console.log(6);
        }
        let gen = getData()//gen是一个iterator对象,调用next方法执行完第一个yield语句
        grn.next()


        function* sync(){
            yield setTimeout(()=>{
                console.log('a');
                fn.next()
            },2000)
            yield setTimeout(()=>{
                console.log('b');
                fn.next()
            },2000)
            yield setTimeout(()=>{
                console.log('c');
                fn.next()
            },2000)
            yield setTimeout(()=>{
                console.log('d');
            },2000)
        }
        let fn = sync()
        fn.next()
    </script>
</body>
</html>